package com.lufei4.chestnut.orbyun;

import android.content.Intent;

import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import com.blankj.utilcode.util.LogUtils;
import com.lufei4.chestnut.Constans;
import com.lufei4.chestnut.R;
import com.lufei4.chestnut.network.BaseActivity;
import com.lufei4.chestnut.orbyun.Broad.MyBroadcastActivity2;
import com.lufei4.chestnut.orbyun.Broad.MyBroadcastReceiver;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @ProjectName: Chestnut
 * @Package: com.lufei4.chestnut.orbyun
 * @ClassName: MyBroadcastActivity
 * @Description: java类作用描述
 * @Author: liushijiang 15833013864@163.com
 * @CreateDate: 2020/9/25 16:32
 * @UpdateUser: 更新者：
 * @UpdateDate: 2020/9/25 16:32
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */

public class MyBroadcastActivity extends BaseActivity {
    @BindView(R.id.button11)
    Button button11;
    @BindView(R.id.button12)
    Button button12;
    @BindView(R.id.button13)
    Button button13;

    @Override
    public int getLayoutId() {
        return R.layout.activity_bro;
    }

    private MyBroadcastReceiver mBroadcastReceiver;

    @Override
    public void initView() {

    }

    private LocalBroadcastManager localBroadcastManager;

    @Override
    protected void onResume() {
        super.onResume();
//
//        mBroadcastReceiver = new MyBroadcastReceiver();
//        IntentFilter intentFilter = new IntentFilter();
//        intentFilter.addAction(Constans.Broad_Action);
//        localBroadcastManager = LocalBroadcastManager.getInstance(this);
//        localBroadcastManager.registerReceiver(mBroadcastReceiver, intentFilter);


    }

    @Override
    protected void onPause() {
        super.onPause();
//        localBroadcastManager.unregisterReceiver(mBroadcastReceiver);
    }

    @OnClick({R.id.button11, R.id.button12, R.id.button13})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.button11:
                LogUtils.d("开始");
                startActivity(new Intent(this, MyBroadcastActivity2.class));
                break;
            case R.id.button12:
                Intent intent = new Intent();
                Bundle bundle = new Bundle();
                bundle.putString("name", "钉钉111");
                intent.putExtra("data", bundle);
                intent.setAction(Constans.Broad_Action);
                LocalBroadcastManager localBroadcastManager=LocalBroadcastManager.getInstance(this);
                localBroadcastManager.sendBroadcast(intent);

                break;
            case R.id.button13:
                break;
        }
    }
}
